{extend name="base@:style" /}
{block name="body"}
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <!--头部搜索-->
            <section class="panel panel-padding">
                <form class="layui-form" action='{:url("system/config/getConfig")}'>
                    <div class="layui-form">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input class="layui-input" name="keyword" placeholder="按标题或标识模糊搜索">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button lay-submit class="layui-btn" lay-filter="search">查找</button>
                        </div>
                    </div>
                </form>
            </section>
            <!--列表-->
            <section class="panel panel-padding">
                <div class="group-button">
                    <button class="layui-btn layui-btn-small layui-btn-danger ajax-all" data-name="checkbox" data-params='{"url": "allDelete","confirm":"true","data":"model=Config&id=1"}'>
                        <i class="iconfont">&#xe626;</i> 删除
                    </button>

                    <button class="layui-btn layui-btn-small modal-catch" data-params='{"content":".add-subcat",  "title": "添加配置","type":"1","area":"500px","data":"id=0"}'>
                        <i class="iconfont">&#xe649;</i> 添加
                    </button>
                    <a href="?group=0" class="layui-btn layui-btn-primary layui-btn-small ">
                        全部
                    </a>
                    {volist name="config_group_list" id="vo"}
                    <a href="?group={$vo.key}" class="layui-btn layui-btn-primary layui-btn-small ">
                        {$vo.value}
                    </a>
                    {/volist}
                </div>

                <div id="list" class="layui-form"></div>

                <div class="text-right" id="page"></div>
            </section>
        </div>
    </div>
</div>
<div class="add-subcat">
    <form id="form1" class="layui-form layui-form-pane" data-name="articleCatData" data-tpl="list-tpl" data-render="true" action="save">
        <div class="layui-form-item">
            <label class="layui-form-label">标识</label>
            <div class="layui-input-block">
                <input type="hidden" name="id" />
                <input type="text" name="name" required jq-verify="required" jq-error="请输入标识，英文字母" placeholder="请输入标识，英文字母" autocomplete="off" class="layui-input ">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" required jq-verify="required" jq-error="请输入配置标题" placeholder="请输入配置标题" autocomplete="off" class="layui-input ">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分组</label>
            <div class="layui-inline">
                <select name="group" lay-verify="required">
                    {volist name="config_group_list" id="vo"}
                    <option value="{$vo.key}">{$vo.value}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-inline">
                <select name="type" lay-verify="required">
                    {volist name="config_type_list" id="vo"}
                    <option value="{$vo.key}">{$vo.value}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item ">
            <label class="layui-form-label">配置说明</label>
            <div class="layui-input-block">
                <textarea name="mark" placeholder="请输入说明" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" name="orders" required jq-verify="number" value="100" jq-error="排序必须为数字" placeholder="分类排序" autocomplete="off" class="layui-input ">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <input type="radio" name="state" title="启用" value="1" checked />
                <input type="radio" name="state" title="禁用" value="0" />
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">

                <button class="layui-btn" jq-submit jq-filter="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
{/block}

{block name="each"}
<script id="list-tpl" type="text/html" data-params='{"url":"{:url("system/config/getConfig")}","data":"group={$group}","dataName":"configCatData","pageid":"#page"}'>
    <table id="example" class="layui-table lay-even" data-name="configCatData" data-tplid="list-tpl">
        <thead>
        <tr>
            <th width="30"><input type="checkbox" id="checkall" data-name="checkbox" lay-filter="check" lay-skin="primary"></th>
            <th width="80">序号</th>
            <th width="180">标识</th>
            <th width="222">标题</th>
            <th width="100">分组</th>
            <th width="100">类型</th>
            <th width="100">排序</th>
            <th width="100">状态</th>
            <th >操作</th>
        </tr>
        </thead>
        <tbody>
        {{# layui.each(d.list, function(index, item){ }}
        <tr>
            <td><input type="checkbox" name="checkbox" value="{{ item.id}}" lay-skin="primary"></td>
            <td>{{ item.id}}</td>
            <td>{{ item.name}}</td>
            <td>{{ item.title}}</td>
            <td>{{ item.group}}</td>
            <td>{{ item.type}}</td>
            <td><input type="text" class="layui-input ajax-blur" name="orders" value="{{ item.orders}}"
                       data-params='{"url":"changeOrder","data":"model=Config&id={{ item.id}}"}'></td>
            <td><input type="checkbox" name="state" lay-skin="switch" lay-text="ON|OFF" {{#if (item.state){
                       }}checked="checked" {{# } }} lay-filter="ajax"
                       data-params='{"url":"changeState","data":"model=Config&id={{item.id}}"}'></td>
            <td>

                <button class="layui-btn layui-btn-mini modal-catch" data-params='{"content": ".add-subcat","area":"500px","title":"编辑{{ item.title}}","key":"id={{ item.id }}","type":"1"}'>
                    <i class="iconfont">&#xe653;</i>编辑
                </button>

                <button class="layui-btn layui-btn-mini layui-btn-danger ajax"
                        data-params='{"url": "forceDelete","confirm":"true","data":"model=Config&id={{item.id}}"}'>
                    <i class="iconfont">&#xe626;</i>删除
                </button>
            </td>

        </tr>
        {{# }); }}
        </tbody>

    </table>
</script>
{/block}

{block name="js"}
<script>
    layui.use('list');
</script>
{/block}